{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "fbe2cd15",
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "import json\n",
    "import pandas as pd\n",
    "import time\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Map\n",
    "from pyecharts.faker import Faker\n",
    "from pyecharts.charts import WordCloud\n",
    "from pyecharts.globals import SymbolType\n",
    "from pyecharts.charts import Bar\n",
    "import numpy as np\n",
    "from pyecharts.charts import Scatter\n",
    "import liepin\n",
    "from pyecharts.globals import ThemeType"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "5aeded90",
   "metadata": {},
   "outputs": [],
   "source": [
    "job = 'ui'\n",
    "area = '广州'\n",
    "output_time = '620_1745'\n",
    "df = pd.read_excel(job + \"_liepin_\" + output_time + \".xlsx\")\n",
    "df_PM_gz = df[\n",
    "    [\n",
    "        \"job.labels\",\n",
    "        \"job.refreshTime\",\n",
    "        \"job.title\",\n",
    "        \"job.salary\",\n",
    "        \"job.dq\",\n",
    "        \"job.topJob\",\n",
    "        \"job.requireWorkYears\",\n",
    "        \"job.requireEduLevel\",\n",
    "        \"comp.compStage\",\n",
    "        \"comp.compName\",\n",
    "        \"comp.compIndustry\",\n",
    "        \"comp.compScale\",\n",
    "    ]\n",
    "]\n",
    "df_PM_gz = df_PM_gz.rename(\n",
    "    columns={\n",
    "        \"job.labels\": \"职位标签\",\n",
    "        \"job.refreshTime\": \"职位更新时间\",\n",
    "        \"job.title\": \"职位\",\n",
    "        \"job.salary\": \"薪资\",\n",
    "        \"job.dq\": \"地区\",\n",
    "        \"job.topJob\": \"是否top职位\",\n",
    "        \"job.requireWorkYears\": \"工作年限\",\n",
    "        \"job.requireEduLevel\": \"学历\",\n",
    "        \"comp.compStage\": \"公司融资情况\",\n",
    "        \"comp.compName\": \"公司名称\",\n",
    "        \"comp.compIndustry\": \"行业\",\n",
    "        \"comp.compScale\": \"规模\",\n",
    "    }\n",
    ")\n",
    "非薪资面议 = df_PM_gz[~df_PM_gz[\"薪资\"].str.contains(\"面议|元/天\")]\n",
    "非薪资面议_detail = 非薪资面议[\"薪资\"].apply(lambda x: x.split(\"薪\")[0].split(\"·\")).tolist()\n",
    "平均薪资 = [\n",
    "    (int(i[0].split(\"-\")[0]) + int(i[0].split(\"-\")[1].split(\"k\")[0])) / 2\n",
    "    if len(i) == 1\n",
    "    else round(\n",
    "        (int(i[0].split(\"-\")[0]) + int(i[0].split(\"-\")[1].split(\"k\")[0]))\n",
    "        / 2\n",
    "        * int(i[1])\n",
    "        / 12,\n",
    "        1,\n",
    "    )\n",
    "    for i in 非薪资面议_detail\n",
    "]\n",
    "# 非薪资面议[\"平均薪资\"] = 平均薪资\n",
    "# 非薪资面议.drop(非薪资面议[非薪资面议[\"工作年限\"].str.contains(\"-\") == False].index, inplace=True)\n",
    "# 分地区_平均薪资 = 非薪资面议.groupby(\"地区\").agg({\"平均薪资\": \"median\"})\n",
    "# 分地区_平均薪资_values = [round(i[0], 1) for i in 分地区_平均薪资.values.tolist()]\n",
    "# 分地区_平均薪资_index = 分地区_平均薪资.index.tolist()\n",
    "# 柱状图\n",
    "# c = (\n",
    "#     Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT))\n",
    "#     .add_xaxis([i.split(\"-\")[1] for i in 分地区_平均薪资_index[1:]])\n",
    "#     .add_yaxis(\"地区\", 分地区_平均薪资_values[1:])\n",
    "#     .set_global_opts(\n",
    "#         title_opts=opts.TitleOpts(title=job + \"-\" + area + \"分地区-中位数薪资\"),\n",
    "#         brush_opts=opts.BrushOpts(),\n",
    "#     )\n",
    "# )\n",
    "# c.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "b53a820e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0      经验不限\n",
       "1      1-3年\n",
       "2      3-5年\n",
       "3      3-5年\n",
       "4      1-3年\n",
       "5      经验不限\n",
       "6      3-5年\n",
       "7      3-5年\n",
       "8      3-5年\n",
       "9      经验不限\n",
       "10     3-5年\n",
       "11     3-5年\n",
       "12    5-10年\n",
       "13     3-5年\n",
       "14     1-3年\n",
       "15     3-5年\n",
       "16     3-5年\n",
       "17    5-10年\n",
       "18    5-10年\n",
       "19     3-5年\n",
       "21    5-10年\n",
       "22    5-10年\n",
       "23     1-3年\n",
       "24     经验不限\n",
       "25     3-5年\n",
       "26     3-5年\n",
       "27     3-5年\n",
       "28     1-3年\n",
       "29     1-3年\n",
       "30     1-3年\n",
       "31     3-5年\n",
       "32     1-3年\n",
       "33     1-3年\n",
       "34     3-5年\n",
       "35     3-5年\n",
       "36     3-5年\n",
       "37     3-5年\n",
       "38     1-3年\n",
       "39    5-10年\n",
       "Name: 工作年限, dtype: object"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "非薪资面议['工作年限']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "b95448b7",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>平均薪资</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>工作年限</th>\n",
       "      <th>学历</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"4\" valign=\"top\">1-3年</th>\n",
       "      <th>大专</th>\n",
       "      <td>15.950000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>学历不限</th>\n",
       "      <td>9.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>本科</th>\n",
       "      <td>7.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>统招本科</th>\n",
       "      <td>8.233333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"5\" valign=\"top\">3-5年</th>\n",
       "      <th>大专</th>\n",
       "      <td>19.150000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>学历不限</th>\n",
       "      <td>32.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>本科</th>\n",
       "      <td>13.900000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>本科及以上</th>\n",
       "      <td>14.600000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>统招本科</th>\n",
       "      <td>32.700000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">5-10年</th>\n",
       "      <th>大专</th>\n",
       "      <td>23.550000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>本科</th>\n",
       "      <td>20.550000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>统招本科</th>\n",
       "      <td>35.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"3\" valign=\"top\">经验不限</th>\n",
       "      <th>大专</th>\n",
       "      <td>12.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>学历不限</th>\n",
       "      <td>12.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>统招本科</th>\n",
       "      <td>9.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                  平均薪资\n",
       "工作年限  学历              \n",
       "1-3年  大专     15.950000\n",
       "      学历不限    9.000000\n",
       "      本科      7.000000\n",
       "      统招本科    8.233333\n",
       "3-5年  大专     19.150000\n",
       "      学历不限   32.500000\n",
       "      本科     13.900000\n",
       "      本科及以上  14.600000\n",
       "      统招本科   32.700000\n",
       "5-10年 大专     23.550000\n",
       "      本科     20.550000\n",
       "      统招本科   35.500000\n",
       "经验不限  大专     12.000000\n",
       "      学历不限   12.500000\n",
       "      统招本科    9.000000"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Scatter\n",
    "from pyecharts.faker import Faker\n",
    "\n",
    "\n",
    "df_year_edulevel =  非薪资面议.groupby(['工作年限','学历']).agg({'平均薪资':'mean'})\n",
    "year_list = ['1-3年', '3-5年', '5-10年']\n",
    "edulevel_list = ['大专', '本科', '本科及以上', '统招本科']\n",
    "result_dict = {}\n",
    "df_year_edulevel"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "331b622a",
   "metadata": {},
   "outputs": [],
   "source": [
    "for year in year_list:\n",
    "    for edulevel in edulevel_list:\n",
    "        avg_salary = round(df_year_edulevel.loc[(slice(year, year), edulevel), '平均薪资'][0])\n",
    "        result_dict[f'{year}-{edulevel}'] = avg_salary\n",
    "result_list = list(result_dict.values())\n",
    "                   \n",
    "new_list = []\n",
    "for i in range(0, len(result_list), 3):\n",
    "    new_list.append(result_list[i:i+3])\n",
    "df_year_edulevel.values.tolist()\n",
    "arr = np.array(df_year_edulevel)\n",
    "min_val = round(arr.min())\n",
    "max_val = round(arr.max())\n",
    "c = (\n",
    "    Scatter()\n",
    "    .add_xaxis(year_list)\n",
    "    .add_yaxis(\"大专\", new_list[0])\n",
    "    .add_yaxis(\"本科\", new_list[1])\n",
    "    .add_yaxis(\"本科及以上\", new_list[2])\n",
    "    .add_yaxis(\"统招本科\", new_list[3])\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title=\"Scatter-VisualMap(Size)\"),\n",
    "        visualmap_opts=opts.VisualMapOpts(type_=\"size\", max_=max_val, min_=min_val),\n",
    "    )\n",
    "#     .render(\"test.html\")\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "d0e36041",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/v5/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"da6af311ae7e46458d450f0fa618ad47\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_da6af311ae7e46458d450f0fa618ad47 = echarts.init(\n",
       "                    document.getElementById('da6af311ae7e46458d450f0fa618ad47'), 'white', {renderer: 'canvas'});\n",
       "                var option_da6af311ae7e46458d450f0fa618ad47 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"colorBy\": \"data\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"selectedMode\": false,\n",
       "            \"selectedOffset\": 10,\n",
       "            \"clockwise\": true,\n",
       "            \"startAngle\": 90,\n",
       "            \"minAngle\": 0,\n",
       "            \"minShowLabelAngle\": 0,\n",
       "            \"avoidLabelOverlap\": true,\n",
       "            \"stillShowZeroSum\": true,\n",
       "            \"percentPrecision\": 2,\n",
       "            \"showEmptyCircle\": true,\n",
       "            \"emptyCircleStyle\": {\n",
       "                \"color\": \"lightgray\",\n",
       "                \"borderColor\": \"#000\",\n",
       "                \"borderWidth\": 0,\n",
       "                \"borderType\": \"solid\",\n",
       "                \"borderDashOffset\": 0,\n",
       "                \"borderCap\": \"butt\",\n",
       "                \"borderJoin\": \"bevel\",\n",
       "                \"borderMiterLimit\": 10,\n",
       "                \"opacity\": 1\n",
       "            },\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u5929\\u6cb3\\u533a\",\n",
       "                    \"value\": 13\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u6d77\\u73e0\\u533a\",\n",
       "                    \"value\": 5\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5357\\u6c99\\u533a\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u767d\\u4e91\\u533a\",\n",
       "                    \"value\": 2\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u8d8a\\u79c0\\u533a\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9ec4\\u57d4\\u533a\",\n",
       "                    \"value\": 1\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u589e\\u57ce\\u533a\",\n",
       "                    \"value\": 1\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"40%\",\n",
       "                \"75%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"50%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"show\": true,\n",
       "                \"margin\": 8,\n",
       "                \"formatter\": \"{b}: {c}\"\n",
       "            },\n",
       "            \"labelLine\": {\n",
       "                \"show\": true,\n",
       "                \"showAbove\": false,\n",
       "                \"length\": 15,\n",
       "                \"length2\": 15,\n",
       "                \"smooth\": false,\n",
       "                \"minTurnAngle\": 90,\n",
       "                \"maxSurfaceAngle\": 90\n",
       "            },\n",
       "            \"rippleEffect\": {\n",
       "                \"show\": true,\n",
       "                \"brushType\": \"stroke\",\n",
       "                \"scale\": 2.5,\n",
       "                \"period\": 4\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5929\\u6cb3\\u533a\",\n",
       "                \"\\u6d77\\u73e0\\u533a\",\n",
       "                \"\\u5357\\u6c99\\u533a\",\n",
       "                \"\\u767d\\u4e91\\u533a\",\n",
       "                \"\\u8d8a\\u79c0\\u533a\",\n",
       "                \"\\u9ec4\\u57d4\\u533a\",\n",
       "                \"\\u589e\\u57ce\\u533a\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"left\": \"2%\",\n",
       "            \"top\": \"15%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"Pie-Radius\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ]\n",
       "};\n",
       "                chart_da6af311ae7e46458d450f0fa618ad47.setOption(option_da6af311ae7e46458d450f0fa618ad47);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1dac82890a0>"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Pie\n",
    "from pyecharts.faker import Faker\n",
    "job = 'ui'\n",
    "area = '广州'\n",
    "output_time = '620_1745'\n",
    "df = pd.read_excel(job + \"_liepin_\" + output_time + \".xlsx\")\n",
    "df_PM_gz = df[\n",
    "    [\n",
    "        \"job.labels\",\n",
    "        \"job.refreshTime\",\n",
    "        \"job.title\",\n",
    "        \"job.salary\",\n",
    "        \"job.dq\",\n",
    "        \"job.topJob\",\n",
    "        \"job.requireWorkYears\",\n",
    "        \"job.requireEduLevel\",\n",
    "        \"comp.compStage\",\n",
    "        \"comp.compName\",\n",
    "        \"comp.compIndustry\",\n",
    "        \"comp.compScale\",\n",
    "    ]\n",
    "]\n",
    "地区 = [\n",
    "    i.split(\"-\")[1]\n",
    "    for i in df_PM_gz[\"job.dq\"].value_counts().index.tolist()\n",
    "    if \"-\" in i\n",
    "]\n",
    "岗位个数 = df_PM_gz[\"job.dq\"].value_counts().values.tolist()[1:]\n",
    "c = (\n",
    "    Pie()\n",
    "    .add(\n",
    "        \"\",\n",
    "        [list(z) for z in zip(地区, 岗位个数)],\n",
    "        radius=[\"40%\", \"75%\"],\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title=\"Pie-Radius\"),\n",
    "        legend_opts=opts.LegendOpts(orient=\"vertical\", pos_top=\"15%\", pos_left=\"2%\"),\n",
    "    )\n",
    "    .set_series_opts(label_opts=opts.LabelOpts(formatter=\"{b}: {c}\"))\n",
    ")\n",
    "\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "f583c166",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\10735\\AppData\\Local\\Temp\\ipykernel_4764\\1684925163.py:53: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  非薪资面议[\"平均薪资\"] = 平均薪资\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts':'https://assets.pyecharts.org/assets/v5/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "\n",
       "        <div id=\"133660ed850b42eab703d024142b58a3\" style=\"width:900px; height:500px;\"></div>\n",
       "\n",
       "<script>\n",
       "        require(['echarts'], function(echarts) {\n",
       "                var chart_133660ed850b42eab703d024142b58a3 = echarts.init(\n",
       "                    document.getElementById('133660ed850b42eab703d024142b58a3'), 'white', {renderer: 'canvas'});\n",
       "                var option_133660ed850b42eab703d024142b58a3 = {\n",
       "    \"animation\": true,\n",
       "    \"animationThreshold\": 2000,\n",
       "    \"animationDuration\": 1000,\n",
       "    \"animationEasing\": \"cubicOut\",\n",
       "    \"animationDelay\": 0,\n",
       "    \"animationDurationUpdate\": 300,\n",
       "    \"animationEasingUpdate\": \"cubicOut\",\n",
       "    \"animationDelayUpdate\": 0,\n",
       "    \"aria\": {\n",
       "        \"enabled\": false\n",
       "    },\n",
       "    \"color\": [\n",
       "        \"#5470c6\",\n",
       "        \"#91cc75\",\n",
       "        \"#fac858\",\n",
       "        \"#ee6666\",\n",
       "        \"#73c0de\",\n",
       "        \"#3ba272\",\n",
       "        \"#fc8452\",\n",
       "        \"#9a60b4\",\n",
       "        \"#ea7ccc\"\n",
       "    ],\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"legendHoverLink\": true,\n",
       "            \"realtimeSort\": false,\n",
       "            \"showBackground\": false,\n",
       "            \"stackStrategy\": \"samesign\",\n",
       "            \"cursor\": \"pointer\",\n",
       "            \"barMinHeight\": 0,\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"barGap\": \"30%\",\n",
       "            \"large\": false,\n",
       "            \"largeThreshold\": 400,\n",
       "            \"seriesLayoutBy\": \"column\",\n",
       "            \"datasetIndex\": 0,\n",
       "            \"clip\": true,\n",
       "            \"zlevel\": 0,\n",
       "            \"z\": 2,\n",
       "            \"label\": {\n",
       "                \"show\": false,\n",
       "                \"margin\": 8\n",
       "            },\n",
       "            \"encode\": {\n",
       "                \"x\": \"amount\",\n",
       "                \"y\": \"product\"\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selected\": {},\n",
       "            \"show\": true,\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"itemWidth\": 25,\n",
       "            \"itemHeight\": 14,\n",
       "            \"backgroundColor\": \"transparent\",\n",
       "            \"borderColor\": \"#ccc\",\n",
       "            \"borderWidth\": 1,\n",
       "            \"borderRadius\": 0,\n",
       "            \"pageButtonItemGap\": 5,\n",
       "            \"pageButtonPosition\": \"end\",\n",
       "            \"pageFormatter\": \"{current}/{total}\",\n",
       "            \"pageIconColor\": \"#2f4554\",\n",
       "            \"pageIconInactiveColor\": \"#aaa\",\n",
       "            \"pageIconSize\": 15,\n",
       "            \"animationDurationUpdate\": 800,\n",
       "            \"selector\": false,\n",
       "            \"selectorPosition\": \"auto\",\n",
       "            \"selectorItemGap\": 7,\n",
       "            \"selectorButtonGap\": 10\n",
       "        }\n",
       "    ],\n",
       "    \"tooltip\": {\n",
       "        \"show\": true,\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"showContent\": true,\n",
       "        \"alwaysShowContent\": false,\n",
       "        \"showDelay\": 0,\n",
       "        \"hideDelay\": 100,\n",
       "        \"enterable\": false,\n",
       "        \"confine\": false,\n",
       "        \"appendToBody\": false,\n",
       "        \"transitionDuration\": 0.4,\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"borderWidth\": 0,\n",
       "        \"padding\": 5,\n",
       "        \"order\": \"seriesAsc\"\n",
       "    },\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"name\": \"amount\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"type\": \"category\",\n",
       "            \"show\": true,\n",
       "            \"scale\": false,\n",
       "            \"nameLocation\": \"end\",\n",
       "            \"nameGap\": 15,\n",
       "            \"gridIndex\": 0,\n",
       "            \"inverse\": false,\n",
       "            \"offset\": 0,\n",
       "            \"splitNumber\": 5,\n",
       "            \"minInterval\": 0,\n",
       "            \"splitLine\": {\n",
       "                \"show\": true,\n",
       "                \"lineStyle\": {\n",
       "                    \"show\": true,\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"dataset\": [\n",
       "        {\n",
       "            \"source\": [\n",
       "                [\n",
       "                    49,\n",
       "                    \"\\u6e38\\u620f\\u4ea7\\u4e1a\"\n",
       "                ],\n",
       "                [\n",
       "                    25,\n",
       "                    \"\\u5bb6\\u5177/\\u5bb6\\u5c45\"\n",
       "                ],\n",
       "                [\n",
       "                    24,\n",
       "                    \"\\u4e92\\u8054\\u7f51\"\n",
       "                ],\n",
       "                [\n",
       "                    22,\n",
       "                    \"\\u7535\\u5b50/\\u534a\\u5bfc\\u4f53/\\u96c6\\u6210\\u7535\\u8def\"\n",
       "                ],\n",
       "                [\n",
       "                    22,\n",
       "                    \"\\u6e38\\u620f\"\n",
       "                ],\n",
       "                [\n",
       "                    15,\n",
       "                    \"\\u57f9\\u8bad\\u670d\\u52a1\"\n",
       "                ],\n",
       "                [\n",
       "                    13,\n",
       "                    \"\\u5728\\u7ebf\\u793e\\u4ea4/\\u5a92\\u4f53\"\n",
       "                ],\n",
       "                [\n",
       "                    13,\n",
       "                    \"\\u8ba1\\u7b97\\u673a\\u8f6f\\u4ef6\"\n",
       "                ],\n",
       "                [\n",
       "                    12,\n",
       "                    \"\\u6279\\u53d1/\\u96f6\\u552e\"\n",
       "                ],\n",
       "                [\n",
       "                    9,\n",
       "                    \"\\u7535\\u6c14\\u673a\\u68b0/\\u5668\\u6750\"\n",
       "                ],\n",
       "                [\n",
       "                    8,\n",
       "                    \"\\u5728\\u7ebf\\u6559\\u80b2\"\n",
       "                ],\n",
       "                [\n",
       "                    6,\n",
       "                    \"\\u667a\\u80fd\\u786c\\u4ef6\"\n",
       "                ]\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"text\": \"Dataset normal bar example\",\n",
       "            \"target\": \"blank\",\n",
       "            \"subtarget\": \"blank\",\n",
       "            \"padding\": 5,\n",
       "            \"itemGap\": 10,\n",
       "            \"textAlign\": \"auto\",\n",
       "            \"textVerticalAlign\": \"auto\",\n",
       "            \"triggerEvent\": false\n",
       "        }\n",
       "    ],\n",
       "    \"visualMap\": {\n",
       "        \"show\": true,\n",
       "        \"type\": \"continuous\",\n",
       "        \"min\": 10,\n",
       "        \"max\": 100,\n",
       "        \"text\": [\n",
       "            \"High Salary\",\n",
       "            \"Low Salary\"\n",
       "        ],\n",
       "        \"inRange\": {\n",
       "            \"color\": [\n",
       "                \"#80D0C7\",\n",
       "                \"#0093E9\"\n",
       "            ]\n",
       "        },\n",
       "        \"calculable\": true,\n",
       "        \"inverse\": false,\n",
       "        \"splitNumber\": 5,\n",
       "        \"dimension\": 0,\n",
       "        \"hoverLink\": true,\n",
       "        \"orient\": \"horizontal\",\n",
       "        \"left\": \"center\",\n",
       "        \"padding\": 5,\n",
       "        \"showLabel\": true,\n",
       "        \"itemWidth\": 20,\n",
       "        \"itemHeight\": 140,\n",
       "        \"borderWidth\": 0\n",
       "    }\n",
       "};\n",
       "                chart_133660ed850b42eab703d024142b58a3.setOption(option_133660ed850b42eab703d024142b58a3);\n",
       "        });\n",
       "    </script>\n"
      ],
      "text/plain": [
       "<pyecharts.render.display.HTML at 0x1dac58df9d0>"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pyecharts import options as opts\n",
    "from pyecharts.charts import Bar\n",
    "job = 'ui'\n",
    "area = '广州'\n",
    "output_time = '620_1745'\n",
    "df = pd.read_excel(job + \"_liepin_\" + output_time + \".xlsx\")\n",
    "df_PM_gz = df[\n",
    "    [\n",
    "        \"job.labels\",\n",
    "        \"job.refreshTime\",\n",
    "        \"job.title\",\n",
    "        \"job.salary\",\n",
    "        \"job.dq\",\n",
    "        \"job.topJob\",\n",
    "        \"job.requireWorkYears\",\n",
    "        \"job.requireEduLevel\",\n",
    "        \"comp.compStage\",\n",
    "        \"comp.compName\",\n",
    "        \"comp.compIndustry\",\n",
    "        \"comp.compScale\",\n",
    "    ]\n",
    "]\n",
    "df_PM_gz = df_PM_gz.rename(\n",
    "    columns={\n",
    "        \"job.labels\": \"职位标签\",\n",
    "        \"job.refreshTime\": \"职位更新时间\",\n",
    "        \"job.title\": \"职位\",\n",
    "        \"job.salary\": \"薪资\",\n",
    "        \"job.dq\": \"地区\",\n",
    "        \"job.topJob\": \"是否top职位\",\n",
    "        \"job.requireWorkYears\": \"工作年限\",\n",
    "        \"job.requireEduLevel\": \"学历\",\n",
    "        \"comp.compStage\": \"公司融资情况\",\n",
    "        \"comp.compName\": \"公司名称\",\n",
    "        \"comp.compIndustry\": \"行业\",\n",
    "        \"comp.compScale\": \"规模\",\n",
    "    }\n",
    ")\n",
    "非薪资面议 = df_PM_gz[~df_PM_gz[\"薪资\"].str.contains(\"面议|元/天\")]\n",
    "非薪资面议_detail = 非薪资面议[\"薪资\"].apply(lambda x: x.split(\"薪\")[0].split(\"·\")).tolist()\n",
    "平均薪资 = [\n",
    "    (int(i[0].split(\"-\")[0]) + int(i[0].split(\"-\")[1].split(\"k\")[0])) / 2\n",
    "    if len(i) == 1\n",
    "    else round(\n",
    "        (int(i[0].split(\"-\")[0]) + int(i[0].split(\"-\")[1].split(\"k\")[0]))\n",
    "        / 2\n",
    "        * int(i[1])\n",
    "        / 12,\n",
    "        1,\n",
    "    )\n",
    "    for i in 非薪资面议_detail\n",
    "]\n",
    "非薪资面议[\"平均薪资\"] = 平均薪资\n",
    "\n",
    "df_industry = 非薪资面议.groupby('行业').agg({'平均薪资':'mean'})\n",
    "df_sorted = df_industry.sort_values(by='平均薪资', ascending=False)\n",
    "top_6 = df_sorted.head(6)  # 取前10个\n",
    "bottom_6 = df_sorted.tail(6)  # 取后10个\n",
    "df_sorted = pd.concat([top_6, bottom_6])\n",
    "行业 = df_sorted.index.tolist()\n",
    "薪资 = df_sorted.values.tolist()\n",
    "arr = []\n",
    "for i in range(len(行业)):\n",
    "    d = {'industry': 行业[i], 'salary': 薪资[i]}\n",
    "    arr.append(d)\n",
    "newarr = []\n",
    "for item in arr:\n",
    "    salary = round(item['salary'][0])\n",
    "    newarr.append([salary, item['industry']])\n",
    "    \n",
    "c = (\n",
    "    Bar()\n",
    "    .add_dataset(\n",
    "        newarr\n",
    "    )\n",
    "    .add_yaxis(\n",
    "        series_name=\"\",\n",
    "        y_axis=[],\n",
    "        encode={\"x\": \"amount\", \"y\": \"product\"},\n",
    "        label_opts=opts.LabelOpts(is_show=False),\n",
    "    )\n",
    "    .set_global_opts(\n",
    "        title_opts=opts.TitleOpts(title=\"Dataset normal bar example\"),\n",
    "        xaxis_opts=opts.AxisOpts(name=\"amount\"),\n",
    "        yaxis_opts=opts.AxisOpts(type_=\"category\"),\n",
    "        visualmap_opts=opts.VisualMapOpts(\n",
    "            orient=\"horizontal\",\n",
    "            pos_left=\"center\",\n",
    "            min_=10,\n",
    "            max_=100,\n",
    "            range_text=[\"High Salary\", \"Low Salary\"],\n",
    "            dimension=0,\n",
    "            range_color=[\"#80D0C7\", \"#0093E9\"],\n",
    "        ),\n",
    "    )\n",
    "\n",
    "\n",
    "\n",
    ")\n",
    "c.render_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "577d55f3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import app"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4aa9e2f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install flask"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
